%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plots Figure 2
%
% need to run Stata Code MainRun.do first       
%
% Cloyne, Dimsdale and Hürtgen (2024) 								
%	"Are Tax Cuts Contractionary at the Zero Lower Bound? Evidence from a Century of Data"  	  		
%																			
% James Cloyne, Nicholas Dimsdale and Patrick Hürtgen, 2024
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

close all;
clear all;
clc;
% LOAD SHOCKS
narrativeShock.Baseline =  readtable('../NarrativeShocks/Figure2.xlsx','ReadRowNames',true);

narrativeShock.Baseline{:,:}(isnan(narrativeShock.Baseline{:,:})) = 0; % Fill NaN values

%% Save plot of baseline shocks

startDate = datenum('01-01-1918');
endDate = datenum('12-31-2020');
xData = linspace(startDate,endDate,size([eval(strcat('narrativeShock.Baseline.N_TaxToGDP')),...
    eval(strcat('narrativeShock.Baseline.X_TaxToGDP'))],1));

Data = [eval(strcat('narrativeShock.Baseline.N_TaxToGDP')),...
    eval(strcat('narrativeShock.Baseline.X_TaxToGDP'))];

xlim = ([xData(1) xData(end)]);

figure('Renderer', 'painters', 'Position', [10 10 900 500])

plot(xData,Data(:,1),'LineWidth',0.8,'LineStyle','--');
set(gca, 'ColorOrder', [0.7 0 0 ; 0 0 0.6], 'NextPlot', 'replacechildren','XGrid','on');   
    hold on;
    plot(xData,Data(:,2),'LineWidth',0.8);
    legend('Endogenous changes','Exogenous changes');
    datetick('x','yyyy','keeplimits');
    ylabel('Percent of GDP');
    xlabel('Year');
box off

saveas(gca, 'Figure2', 'pdf')
saveas(gca, 'Figure2', 'epsc2')

